/**
 * Copyright (C), 2015-2018, XXX有限公司
 * FileName: DictWrapper
 * Author:   zhouheng
 * Date:     2018/7/19 20:48
 * Description: 字典包装类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.hengby.hengcrud.modular.sys.warpper;

import com.hengby.hengcrud.core.common.factory.ConstantFactory;
import com.hengby.hengcrud.core.util.ToolUtil;
import com.hengby.hengcrud.modular.base.wrap.BaseControllerWarpper;
import com.hengby.hengcrud.modular.sys.model.Dict;

import java.util.List;
import java.util.Map;

/**
 * 〈一句话功能简述〉<br> 
 * 〈字典包装类〉
 *
 * @author zhouheng
 * @create 2018/7/19
 * @since 1.0.0
 */
public class DictWrapper extends BaseControllerWarpper{

    public DictWrapper(Object obj) {
        super(obj);
    }

    @Override
    protected void warpTheMap(Map<String, Object> map) {
        StringBuffer detail = new StringBuffer();
        Integer id = (Integer) map.get("id");
        List<Dict> dicts = ConstantFactory.me().findInDict(id);
        if(dicts != null){
            for (Dict dict : dicts) {
                detail.append(dict.getNum() + ":" +dict.getName() + ",");
            }
            map.put("detail", ToolUtil.removeSuffix(detail.toString(),","));
        }
    }
}